import os
import sys
# from SpiderModel.models import WeiboCookie
#
# def writeCookies(key,value):
#     WeiboCookie.objects.filter(cookie_key=key).update(cookie_value=value)
#
# def readCookie(key):
#     cookie = WeiboCookie.objects.filter(cookie_key=key)
#     for i in cookie:
#         return i.cookie_value



pa =os.path.dirname(__file__)+"\\cookies.py"
def writeCookies(key,value):
    f =open(pa,'r',encoding='utf-8')
    content = eval(f.read())
    f.close()
    content[key] = value
    f =open(pa,'w',encoding='utf-8')
    f.write(str(content))
    f.close()

def readCookie(key):
    f =open(pa,'r',encoding='utf-8')
    content = eval(f.read())
    f.close()
    return content[key]
